<template>
  <div class="app-container">
    <!-- 添加或修改面试信息列表对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="学生id" prop="studentId">
          <el-input v-model="form.studentId" placeholder="请输入学生id" />
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="面试日期" prop="interviewDate">
          <el-date-picker clearable
            v-model="form.interviewDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择面试日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="公司名称" prop="companyName">
          <el-input v-model="form.companyName" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="公司地址" prop="companyAddress">
          <el-input v-model="form.companyAddress" placeholder="请输入公司地址" />
        </el-form-item>
        <el-form-item label="公司联系人" prop="companyContact">
          <el-input v-model="form.companyContact" placeholder="请输入公司联系人" />
        </el-form-item>
        <el-form-item label="联系方式" prop="contact">
          <el-input v-model="form.contact" placeholder="请输入联系方式" />
        </el-form-item>
        <el-form-item label="面试结果" prop="interviewResults">
          <el-input v-model="form.interviewResults" placeholder="请输入面试结果" />
        </el-form-item>
        <el-form-item label="面试内容">
          <editor v-model="form.interviewContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="面试总结" prop="interviewSummary">
          <el-input v-model="form.interviewSummary" placeholder="请输入面试总结" />
        </el-form-item>
        <el-form-item label="面试题图片" prop="interviewQuestions">
          <el-input v-model="form.interviewQuestions" placeholder="请输入面试题图片" />
        </el-form-item>
        <el-form-item label="面试简历" prop="interviewResume">
          <el-input v-model="form.interviewResume" placeholder="请输入面试简历" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {  addInterviewlist } from "@/api/interview/interviewlist";
export default {
    name: "entryInterview",
    data() {
    return {
    // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 表单校验
      // 表单校验
      rules: {
        studentId: [
          { required: true, message: "学生id不能为空", trigger: "blur" }
        ],
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" }
        ],
        interviewDate: [
          { required: true, message: "面试日期不能为空", trigger: "blur" }
        ],
        companyName: [
          { required: true, message: "公司名称不能为空", trigger: "blur" }
        ],
        companyAddress: [
          { required: true, message: "公司地址不能为空", trigger: "blur" }
        ],
        companyContact: [
          { required: true, message: "公司联系人不能为空", trigger: "blur" }
        ],
        contact: [
          { required: true, message: "联系方式不能为空", trigger: "blur" }
        ],
        interviewResults: [
          { required: true, message: "面试结果不能为空", trigger: "blur" }
        ],
        interviewContent: [
          { required: true, message: "面试内容不能为空", trigger: "blur" }
        ],
        interviewSummary: [
          { required: true, message: "面试总结不能为空", trigger: "blur" }
        ],
        interviewResume: [
          { required: true, message: "面试简历不能为空", trigger: "blur" }
        ]
      },
    };
  },
  created() {
      this.reset();
      this.open = true;
      this.title = "添加面试信息";
  },
  methods: {
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加面试信息";
    },
     // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
     // 表单重置
    reset() {
      this.form = {
        interviewId: null,
        studentId: null,
        name: null,
        interviewDate: null,
        companyName: null,
        companyAddress: null,
        companyContact: null,
        contact: null,
        interviewResults: null,
        interviewContent: null,
        interviewSummary: null,
        interviewQuestions: null,
        interviewResume: null
      };
      this.resetForm("form");
    },
     /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.interviewId != null) {
            updateInterviewlist(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInterviewlist(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    
  },
}
</script>

<style>

</style>